package com.hs.srm.admin.modules.ssess.service.impl;


import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hs.srm.admin.modules.ssess.dao.SsessDao;
import com.hs.srm.admin.modules.ssess.entity.SsessEntity;
import com.hs.srm.admin.modules.ssess.service.SsessService;
import com.hs.srm.admin.modules.ssess.vo.SsessVO;
import com.hs.srm.admin.modules.vendor.vo.SimpleVendorInfoVO;
import com.hs.srm.base.common.annotation.DataFilter;
import com.hs.srm.base.common.utils.Constant;
import com.hs.srm.base.common.utils.QueryParam;
import com.hs.srm.common.utils.PageUtils;

/**
 * @author yanfei
 *
 * @date 2019年3月25日
 */
@Service("ssessService")
public class SsessServiceImpl extends ServiceImpl<SsessDao, SsessEntity> implements SsessService {

	
	@Override
	@DataFilter
	public PageUtils queryPage(Map<String, Object> params) {
		String vendorName = (String)params.get("vendorName");
		String vendorCode = (String)params.get("vendorCode");
		Page<SsessEntity> page = this.selectPage(
				new QueryParam<SsessEntity>(params).getPage(),
				new EntityWrapper<SsessEntity>()
						.like(StringUtils.isNotBlank(vendorName), "vendor_name", vendorName)
						.like(StringUtils.isNotBlank(vendorCode), "vendor_code", vendorCode)
						.addFilterIfNeed(!ObjectUtils.isEmpty(params.get(Constant.SQL_FILTER)),
								(String)params.get(Constant.SQL_FILTER)));
		return new PageUtils(page);
	}

	@Override
	public SsessEntity findByCodeAndfactory(String vendorcode,String factory) {
	
		return this.baseMapper.findByCodeAndfactory(vendorcode,factory);
	}

	@Override
	public List<SsessVO> findBySsessAndQuota(Date begindate,Date enddate) {
		
		return this.baseMapper.findBySsessAndQuota(begindate,enddate);
	}

	@Override
	public SsessEntity findByVendorCode(String vendorcode) {
		
		return this.baseMapper.findByVendorCode(vendorcode);
	}

	@Override
	public int findCount(String vendorcode, String factory) {
		
		return this.baseMapper.findCount(vendorcode, factory);
	}

	@Override
	public SsessEntity findByCodeAndfactoryAnddate(String vendorcode, String factory,
			Date begindate, Date enddate) {
		
		return this.baseMapper.findByCodeAndfactoryAnddate(vendorcode, factory, begindate, enddate);
	}

	@Override
	public SsessEntity findBySesss(String vendorcode, String factory,
			String materialCode) {
		
		return this.baseMapper.findBySesss(vendorcode, factory, materialCode);
	}

}
